import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { VarietiesVO, VarietiesForm, VarietiesQuery } from '@/api/pig/varieties/types';

/**
 * 查询品种管理列表
 * @param query
 * @returns {*}
 */

export const listVarieties = (query?: VarietiesQuery): AxiosPromise<VarietiesVO[]> => {
  return request({
    url: '/pig/varieties/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询品种管理详细
 * @param id
 */
export const getVarieties = (id: string | number): AxiosPromise<VarietiesVO> => {
  return request({
    url: '/pig/varieties/' + id,
    method: 'get'
  });
};

/**
 * 新增品种管理
 * @param data
 */
export const addVarieties = (data: VarietiesForm) => {
  return request({
    url: '/pig/varieties',
    method: 'post',
    data: data
  });
};

/**
 * 修改品种管理
 * @param data
 */
export const updateVarieties = (data: VarietiesForm) => {
  return request({
    url: '/pig/varieties',
    method: 'put',
    data: data
  });
};

/**
 * 删除品种管理
 * @param id
 */
export const delVarieties = (id: string | number | Array<string | number>) => {
  return request({
    url: '/pig/varieties/' + id,
    method: 'delete'
  });
};
